package com.habdqn.studentmanager.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.habdqn.studentmanager.bean.Dictionary;
import com.habdqn.studentmanager.exception.StudentException;
import com.habdqn.studentmanager.mapper.DictionaryMapper;
import com.habdqn.studentmanager.service.DictionaryService;

/**
 * @author Administrator
 * 
 *         2017年5月18日
 * 
 */
@Service
public class DictionaryServiceImpl implements DictionaryService {
	private static Logger logger = Logger.getLogger(DictionaryServiceImpl.class);
	@Resource
	private DictionaryMapper dictMapper;

	@Override
	public List<Dictionary> findList(Dictionary bean) {

		List<Dictionary> lists = null;
		
		try {
			lists = dictMapper.findList(bean);
		}
		catch (RuntimeException e) {
			logger.error("system error", e);
			throw new StudentException("查询枚举信息失败", e);
		}
		
		return lists;
	}

	@Override
	public Integer findValue(int type,String name) {
		int value=-1;
		try {
			value = dictMapper.findValue(type, name);
		}
		catch (RuntimeException e) {
			logger.debug("查询失败", e);
			throw new StudentException("查询失败",e);
		}
		return value;
	}

}
